vector<string> topKFrequent(vector<string>& words, int k) {
    vector<string> v(k);
    unordered_map<string, int> hash;
    for (auto ch : words)
        hash[ch]++;
    priority_queue<value, vector<value>, cmp> q;
    for (auto ch : hash)
    {
        q.push(ch);
        if (q.size() > k) q.pop();
    }
    for (int i = k - 1; i >= 0; i--)
    {
        v[i] = q.top().first;
        q.pop();
    }
    return v;
}
};
class MedianFinder {
public:
    priority_queue<int, vector<int>, less<int>> left;
    priority_queue<int, vector<int>, greater<int>> right;
    MedianFinder() {

    }

    void addNum(int num) {
        int sizel = left.size();
        int sizer = right.size();
        if (sizel == sizer)
        {
            if (left.empty() || num <= left.top())
                left.push(num);
            else
            {
                right.push(num);
                int cur = right.top();
                right.pop();
                left.push(cur);
            }
        }
        else
        {
            if (num <= left.top())
            {
                left.push(num);
                int cur = left.top();
                left.pop();
                right.push(cur);
            }
            else
                right.push(num);
        }
    }

    double findMedian() {
        int sizel = left.size();
        int sizer = right.size();
        if (sizel == sizer) return (left.top() + right.top()) * 1.0 / 2;
        else return left.top() * 1.0;
    }
};

/**
 * Your MedianFinder object will be instantiated and called as such:
 * MedianFinder* obj = new MedianFinder();
 * obj->addNum(num);
 * double param_2 = obj->findMedian();
 */